<template>
  <div>
    <el-card shadow="never" header="完工销户申请">
      <el-table
        ref="tableRef"
        v-loading="completedLoading"
        :data="completedList"
        style="width: 100%"
        :show-overflow-tooltip="{ effect: 'light' }"
      >
        <el-table-column label="项目名称" prop="projectName" min-width="250" />
        <el-table-column label="项目编号" prop="projectNum" min-width="200" />
        <el-table-column label="项目类型" prop="categoryName" min-width="100" />
        <el-table-column label="建设性质" prop="propertyNumName" min-width="80" />
        <el-table-column label="审核状态" prop="auditTypeName" min-width="80">
          <template #default="scope">
            <span v-if="scope.row.auditType == 0">
              <el-text type="warning"> {{ scope.row.auditTypeName }} </el-text>
            </span>
            <span v-if="scope.row.auditType == 1">
              <el-text type="success"> {{ scope.row.auditTypeName }} </el-text>
            </span>
            <span v-if="scope.row.auditType == -1">
              <el-tooltip class="box-item" effect="light" :content="scope.row.refundReason" placement="top">
                <el-text type="danger"> {{ scope.row.auditTypeName }} </el-text>
              </el-tooltip>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="申请理由" prop="applyReason" min-width="200" />
        <el-table-column label="申请时间" prop="createTime" min-width="120" />
        <el-table-column label="实际竣工日期" prop="endDate" min-width="120" />
        <el-table-column label="计划竣工日期" prop="contractEndDate" min-width="120" />
      </el-table>
    </el-card>

    <el-card shadow="never" header="停复工核实申请">
      <el-table
        v-loading="workapplyLoading"
        :data="workapplyList"
        style="width: 100%"
        :show-overflow-tooltip="{ effect: 'light' }"
      >
        <el-table-column label="项目种类" prop="fundsSourceName" min-width="120" />
        <el-table-column label="项目类型" prop="categoryName" min-width="100" />
        <el-table-column label="建设性质" prop="propertyNumName" min-width="80" />
        <el-table-column label="申请状态" prop="statusName" min-width="80" />
        <el-table-column label="申请理由" prop="reason" min-width="200" />
        <el-table-column label="审核状态" prop="auditTypeName" min-width="80">
          <template #default="scope">
            <span v-if="scope.row.auditType == 0">
              <el-text type="warning"> {{ scope.row.auditTypeName }} </el-text>
            </span>
            <span v-if="scope.row.auditType == 1">
              <el-text type="success"> {{ scope.row.auditTypeName }} </el-text>
            </span>
            <span v-if="scope.row.auditType == -1">
              <el-text type="danger"> {{ scope.row.auditTypeName }} </el-text>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="实际开工时间" prop="startDate" min-width="120" />
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { QueryProjectCompletedList } from "@/api/project/completed/index";
import { QueryProjectLockOutList } from "@/api/project/workapply/index";
const completedLoading = ref<boolean>(true);
const completedList = ref<any[]>([]);
const workapplyLoading = ref<boolean>(true);
const workapplyList = ref<any[]>([]);

const props = defineProps({
  id: {
    type: Number,
    default: 0,
  },
});
const { id } = toRefs(props);

const initCompleted = () => {
  QueryProjectCompletedList({ pageNum: 1, pageSize: 9999, projectId: id.value })
    .then((res) => {
      if (res.success) {
        completedList.value = res.data.list;
      }
    })
    .finally(() => {
      completedLoading.value = false;
    });
};
const initWorkApply = () => {
  QueryProjectLockOutList({ pageNum: 1, pageSize: 9999, projectId: id.value })
    .then((res) => {
      if (res.success) {
        workapplyList.value = res.data.list;
      }
    })
    .finally(() => {
      workapplyLoading.value = false;
    });
};

onMounted(() => {
  initCompleted();
  initWorkApply();
});
</script>

<style scoped>
:deep(.el-card) {
  border: 0;
  padding-top: 20px;
}
:deep(.el-card .el-card__header) {
  font-weight: bold;
  color: black;
  font-size: 14px;
}
</style>
